package com.luhuiguo.cms.client.ui;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.luhuiguo.cms.client.presenter.MainPresenter;

@Singleton
public class MainView extends Composite implements MainPresenter.Display {

    private static MainViewUiBinder uiBinder = GWT.create(MainViewUiBinder.class);

    interface MainViewUiBinder extends UiBinder<Widget, MainView> {
    }

    @UiField
    LayoutPanel centerContainer;

    @Inject
    public MainView() {

        initWidget(uiBinder.createAndBindUi(this));
        GWT.log("MainView created");
    }

    @Override
    public Widget asWidget() {
        return this;
    }

    @Override
    public void addWidget(Widget widget) {
        // showWidget(widget);
    }

    @Override
    public void removeWidget(Widget widget) {
        // centerContainer.remove(widget);
    }

    @Override
    public void showWidget(Widget widget) {
        centerContainer.clear();
        centerContainer.add(widget);

        // centerContainer.setWidget(widget);

    }

}
